<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OA协同办公系统</title>
<link href="css/table.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="js/kindeditor/plugins/code/prettify.css" />
<link rel="stylesheet" href="js/kindeditor/themes/default/default.css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="js/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="js/kindeditor/plugins/code/prettify.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script type="text/javascript" src="js/file.js"></script>
<script type="text/javascript" src="js/mail.js"></script>
<script type="text/javascript">
 function loadFile(val){
		var fileId=$("#fileArray").val();
		if(fileId!=''&&fileId!='null'){
			var param={"fileArray":fileId};
			$.post("getFileList.action",param,function(data) {
				var list=data.fileList;
				for(var i=0;i<list.length;i++){
					$("#"+val).prepend("<tr><td><input type=\"checkbox\" name=\"checkbox2\" id=\""+list[i].id+"\" value=\""+list[i].id+"\" />&nbsp;<a href=\"downLoadFile.action?fileId="+list[i].id+"\">"+list[i].name+"</a>&nbsp;</tr>");
		        }
			},"json");
		}
	}
	
function addUpload(de,name){
	var servedTo="";
	var servedTo2="";
	if(de=='copyTo'){
		servedTo="<td width=\"50px\">抄送人</td><td><textarea class=\"textinput\"  readonly=\"readonly\" id=\"cnames\" style=\"height:30px;\" name=\"draftMail.CNames\">${draftMail.CNames}</textarea><input type=\"hidden\" id=\"cids\" name=\"draftMail.CIds\" value=\"${draftMail.CIds}\"></td>";
		servedTo2="<td width=\"50px\"></td> <td><a href=\"javascript:selectUser('c')\">添加抄送人</a></td>";
	}else if(de=='bcc'){
		servedTo="<td width=\"50px\">密送人</td> <td><textarea class=\"textinput\"  readonly=\"readonly\" id=\"mnames\" style=\"height:30px;\" name=\"draftMail.MNames\">${draftMail.MNames}</textarea><input type=\"hidden\" id=\"mids\" name=\"draftMail.MIds\" value=\"${draftMail.MIds}\"></td>";
		servedTo2="<td width=\"50px\"></td><td><a href=\"javascript:selectUser('m')\">添加密送人</a></td>";
	}
	$("#"+de+"1").html(servedTo);$("#"+de+"2").html(servedTo2);
	$("#"+de).html("删除"+name).attr("href","javascript:deleteddd('"+de+"','"+name+"')");
}
function deleteddd(dd,name){
	$("#"+dd+"1").html("");$("#"+dd+"2").html("");
	$("#"+dd).html("添加"+name).attr("href","javascript:addUpload('"+dd+"','"+name+"')");
}
</script>
</head>

<body onload="loadFile('filetable')">
<form action="" name="mailForm" method="post">
<input type="hidden" id="fileArray" name="draftMail.fileId" value="${draftMail.fileId}">
<input type="hidden" name="reply" value="${reply}">
<input type="hidden" id="status" value="${statu}">
<div class="divborder">
	<table class="tablemail">
		<tr>
			<td width="50px">收件人</td>
			<td><textarea class="textinput"  readonly="readonly" id="snames" style="height:30px;" name="draftMail.receiverNames">${draftMail.receiverNames}</textarea>
			<input type="hidden" id="sids" name="draftMail.receiverIds" value="${draftMail.receiverIds}">
			</td>
		</tr>
			<tr>
			<td width="50px"></td>
			<td><a href="javascript:selectUser('s')">添加收件人</a>-<a id="copyTo" href="javascript:addUpload('copyTo','抄送')">添加抄送</a>-<a id="bcc" href="javascript:addUpload('bcc','密送')">添加密送</a></td>
		</tr >
		<tr id="copyTo1">
			
		</tr>
		<tr id="copyTo2">
			
		</tr>
		<tr id="bcc1">
			
		</tr>
		<tr id="bcc2">
			
		</tr>
		<tr>
        	<td>主题</td><td><input class="textinput" id="title"  name="draftMail.title" value="${draftMail.title}" maxlength="50"/></td>
        </tr>
		<tr>
        	<td></td><td><a href="javascript:file_upload('filetable')">添加附件</a>&nbsp;&nbsp;<a href="javascript:fileDel('filetable')">删除</a></td>
		</tr>
		<tr><td></td>
        	<td>
				<table id="filetable" style="border:#cddee9 double 2px; width:670px">
					
				</table>
			</td>
         </tr>
         <tr>
         	<td valign="top">正文</td>
            <td>
      		<textarea name="content" id="content" style="width:95%;height:300px;visibility:hidden;">${content}</textarea>
           </td>
         </tr>
         <tr>
         	<td></td>
            <td>
            	<input name="draftMail.back" type="checkbox"  value="1"/>需回执&nbsp;&nbsp;&nbsp;
            	<input name="draftMail.status" type="checkbox"  value="紧急" />紧急&nbsp;
            	&nbsp;&nbsp;<input name="draftMail.msg" type="checkbox"  value="1"/>短信提醒
            </td>
         </tr>
	</table>
	<div  style="margin-left:105px; margin-top:5px">
    <input  class="button_04" onclick="valiadValue('send')" type="button" value="发送" />&nbsp;&nbsp;
</div>
</div>
</form>
</body>
</html>